package com.nulldev.util.web.HttpServer3.extensions.flexiProxy;

import java.util.Map;

import com.nulldev.util.data.Variables;
import com.nulldev.util.internal.backport.concurrency9.Maps;

public class FlexiProxyBuilder {

	private boolean blockedNonRuledPages;
	private Map<String, FlexiProxyRule> rules = Maps.of();
	private Map<String, FlexiProxyHandler> handlers = Maps.of();
	private String page = null;

	public FlexiProxyBuilder() {
	}

	public FlexiProxyBuilder withRules(final Map<String, FlexiProxyRule> rules) {
		this.rules = Variables.requireNonNullObject(rules, "rules");
		return this;
	}

	public FlexiProxyBuilder withHandlers(final Map<String, FlexiProxyHandler> handlers) {
		this.handlers = Variables.requireNonNullObject(handlers, "handlers");
		return this;
	}

	public FlexiProxyBuilder pageName(final String name) {
		this.page = Variables.requireNonNullObject(name, "name");
		return this;
	}

	public FlexiProxyPage build() {
		Variables.requireNonNull(this.page, "page");
		return new FlexiProxyPage(this.page, this.rules, this.handlers, this.blockedNonRuledPages);
	}
}